unit uDMCons;

interface

uses
  SysUtils, Classes, FMTBcd, DB, SqlExpr, Provider, DBClient, SqlTimSt;

type

  TdmCons = class(TDataModule)
    dspCons: TDataSetProvider;
    sqlCons: TSQLDataSet;
    ClientDataSet1: TClientDataSet;
    qryConsHorario: TSQLQuery;
  private
    { Private declarations }
  public
    function isValidaReserva(idMedico: integer; DataHoraInicio, DataHoraFim: TDateTime):boolean;
  end;

var
  dmCons: TdmCons;

implementation

uses uDM;

{$R *.dfm}

{ TdmCons }

function TdmCons.isValidaReserva(idMedico: integer; DataHoraInicio,
  DataHoraFim: TDateTime): boolean;
begin
  with qryConsHorario do
  begin
    Params[0].AsInteger := idMedico;
    Params[1].AsSQLTimeStamp := DateTimeToSQLTimeStamp(DataHoraInicio);
    Params[2].AsSQLTimeStamp := DateTimeToSQLTimeStamp(DataHoraFim);
    Open;
    result := (RecordCount = 1);
    Close;
  end;
end;

end.
